package com.roper.yygh.hosp.controller;

import com.roper.yygh.common.result.Result;
import com.roper.yygh.hosp.service.HospitalService;
import com.roper.yygh.model.hosp.Hospital;
import com.roper.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/**
 * Description: 医院列表接口
 * Date:      2022/1/1 11:09
 * author:    LPH
 * version:   V1.0
 */
@Api(tags = "医院列表接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
// 跨域问题
@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    // 医院列表展示
    @ApiOperation("医院列表查询接口")
    @GetMapping("list/{page}/{limit}")
    public Result findAllHospital(@PathVariable int page,
                                  @PathVariable int limit,
                                  HospitalQueryVo hospitalQueryVo) {
        Page pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }

    // 医院详情展示
    @ApiOperation("医院详情展示接口")
    @GetMapping("showHosp/{id}")
    public Result showHosp(@PathVariable String id) {
        Hospital hospital = hospitalService.showHosp(id);
        return Result.ok(hospital);
    }

    // 医院上线下线通知
    @ApiOperation("医院上线下线接口")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id,
                                   @PathVariable Integer status) {
        hospitalService.updateHospStatus(id, status);
        return Result.ok();
    }

}
